<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Serialization Sample</title>
    <link href="description/Galleries.css" type="text/css" rel="Stylesheet" /><link href="description/Layout.css" type="text/css" rel="Stylesheet" /><link href="description/Brand.css" type="text/css" rel="Stylesheet" />
    <link href="description/iframedescription.css" rel="Stylesheet" type="text/css" />
    <script src="description/offline.js" type="text/javascript"></script>
    <style type="text/css">
        #projectInfo {
            overflow: auto;
        }
        #longDesc {
            clear:both;
            margin: 25px 0 10px 0;
        }

        #SampleIndexList{
        margin-left: 15px;
        }
    </style>
</head>
<body>
    <div id="offlineDescription">
        <div id="projectInfo">
            <div class="section">
                    <div class="itemBarLong tagsContainer">
                        <label for="Technologies">Technologies</label>
                        <div id="Technologies">
                            .NET Framework
                        </div>
                    </div>
                    <div class="itemBarLong tagsContainer">
                        <label for="Topics">Topics</label>
                        <div id="Topics">
                            Serialization
                        </div>
                    </div>
                <div class="itemBar">
                    <label for="LastUpdated">Last Updated</label>
                    <div id="LastUpdated">11/30/2011</div>
                </div>
                <div class="itemBarLong">
                    <label for="License">License</label>
                    <div id="License">
                        <a href="license.rtf">MS-LPL</a></div>
                </div>
            </div>
        </div>
        
                   
<script type="text/javascript">
    function initializePage() {
        var otherTabClass = 'otherTab';
        var hiddenPreClass = 'hidden';

        var htmlDecode = function(encodedData) {
            var decodedData = "";
            if (encodedData) {
                var div = document.createElement('div');
                div.innerHTML = encodedData;
                decodedData = div.firstChild.nodeValue.replace( /\\r\\n/ig , '\r\n');
            }
            return decodedData;
        };
                
        Galleries.iterateElem(Galleries.findElem(null, 'div', 'scriptcode'), function (index, scriptBlock) {
            var titleElem = Galleries.findElem(scriptBlock, 'div', 'title')[0];
            var labelElems = Galleries.findElem(titleElem, 'span');
            if (labelElems.length == 0) {
                labelElems = titleElem;
            }
            var languageSpans = Galleries.findElem(scriptBlock, 'span', 'hidden');
            var pres = Galleries.findElem(scriptBlock, 'pre');
            if (languageSpans.length > 0 && pres.length > 1) {
                Galleries.iterateElem(labelElems, function(index, elem) {
                    var codePre = pres[index];
                    var labelSpan = elem;
                    var languageSpan = languageSpans[index];
                            
                    elem.code = codePre.innerHTML.replace( /(\r(\n)?)|((\r)?\n)/ig , '\\r\\n');
                            
                    codePre.className = codePre.className.replace(hiddenPreClass, '');
                            
                    languageSpan.parentNode.removeChild(languageSpan);
                });

                pres = Galleries.findElem(scriptBlock, 'pre');
                Galleries.iterateElem(labelElems, function(index, elem) {
                    var codePre = pres[index];
                    var labelSpan = elem;
                    if (index == 0) {
                        scriptBlock.activeTab = 0;
                    }
                    else {
                        labelSpan.className += otherTabClass;
                        codePre.className += hiddenPreClass;
                    }
                    Galleries.attachEventHandler(labelSpan, 'click', function(e) {
                        var activeTab = scriptBlock.activeTab;
                        labelElems[activeTab].className += otherTabClass;
                        pres[activeTab].className += hiddenPreClass;

                        codePre.className = codePre.className.replace(hiddenPreClass, '');
                        labelSpan.className = labelSpan.className.replace(otherTabClass, '');
                        scriptBlock.activeTab = index;
                    });
                });

                var preview = Galleries.findElem(scriptBlock, 'div', 'preview');
                if (preview.length == 0) {
                    preview.push(pres[pres.length - 1]);
                }
                Galleries.iterateElem(preview, function(index, elem) {
                    elem.parentNode.removeChild(elem);
                });

                if (window.clipboardData && clipboardData.setData) {
                    var copyLink = document.createElement('a');
                    copyLink.href = 'javascript:void(0);';
                    copyLink.className = 'copyCode';
                    copyLink.innerHTML = 'Copy Code';
                    Galleries.attachEventHandler(copyLink, 'click', function (e) {
                        clipboardData.setData("Text", htmlDecode(labelElems[scriptBlock.activeTab].code));
                        return false;
                    });
                    scriptBlock.insertBefore(copyLink, scriptBlock.childNodes[0]);
                }
            }
        });
    }

    Galleries.onWindowLoad(function(){
        initializePage();
    });

</script>
<div id="longDesc">
    
<h1>Serialization Sample</h1>
<div id="mainSection">
<div id="mainBody">
<div class="saveHistory" id="allHistory">
<p>&nbsp;</p>
</div>
<div class="introduction">
<p>To get samples and instructions for installing them, see the following:</p>
<ul>
<li>
<p>Click <span class="ui">Samples</span> on the Visual Studio <span class="ui">
Help</span> menu.</p>
<p>For more information, see .</p>
</li><li>
<p>The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.</p>
</li><li>
<p>You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.</p>
<div class="alert">
<table width="100%">
</table>
<p>&nbsp;</p>
</div>
</li></ul>
</div>
<h3 class="procedureSubHeading">To run this sample</h3>
<div class="subSection">
<ul>
<li>
<p>Press F5.</p>
</li></ul>
</div>
<h1 class="heading"><span>Demonstrates</span></h1>
<div class="section" id="demonstratesSection">
<p>This application contains two classes, one with standard serialization and one with custom serialization. The user interface includes buttons to serialize and deserialize the two classes. The class with standard serialization can be serialized to either
 a SOAP file or a binary file. The class with custom serialization is serialized to a SOAP file. A control is used to display the SOAP files. The two classes both have the attribute. The classes are described in the following table.</p>
<div class="tableSection">
<table cellspacing="2" cellpadding="5" width="50%" frame="lhs">
<tbody>
<tr>
<th>
<p>Class Member</p>
</th>
<th>
<p>SerializationClass</p>
</th>
<th>
<p>CustomSerializationClass</p>
</th>
</tr>
<tr>
<td>
<p><span class="code">PublicVariable</span></p>
</td>
<td>
<p>The public variable is serialized and deserialized without change.</p>
</td>
<td>
<p>The public variable is serialized and deserialized without change.</p>
</td>
</tr>
<tr>
<td>
<p><span class="code">PublicProperty</span></p>
</td>
<td>
<p>The private variable that supports the property is serialized and deserialized without change.</p>
</td>
<td>
<p>The private variable that supports the property is serialized as -1, regardless of the value set in the user interface. It is therefore deserialized as -1.</p>
</td>
</tr>
<tr>
<td>
<p><span class="code">NonSerializedVariable</span></p>
</td>
<td>
<p>This variable is not serialized, because it is marked with the . The public variable is not serialized, and the deserialized value is 0.</p>
</td>
<td>
<p>Though the variable is marked by the , it is serialized, because the custom serialization overrides this setting. The public variable is serialized and deserialized without change.</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>Three types of serialization are demonstrated:</p>
<ul>
<li>
<p><span class="label">SOAP formatting</span>&nbsp;&nbsp;&nbsp;<span class="code">Class1</span> is serialized using the class.</p>
</li><li>
<p><span class="label">Binary formatting</span>&nbsp;&nbsp;&nbsp;<span class="code">Class1</span> is serialized using class.</p>
</li><li>
<p><span class="label">Custom formatting</span>&nbsp;&nbsp;&nbsp;<span class="code">Class2</span> implements the interface, including the method to perform custom serialization.</p>
</li></ul>
</div>
</div>
<div id="footer">
<div class="footerLine"></div>
<a name="feedback"></a><span id="fb" class="feedbackcss">&nbsp;</span></div>
</div>

</div>


    </div>
</body>
</html>
